home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/exec.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <functions.h>
- #define NL NULL
- char image[200];
- void sr(char *str);
- void CheckFiles(void);
- void end();
- int CheckForDirs(char PathsFile[]);
- int NumDirs;
- main(int argc,char *argv[])
- {
- if(argc!=2)
- {
- printf("DirStatus v1.0, written by Joseph Hodge\n");
- printf("Usage: DirStatus <conference path>\n");
- printf(" ie: DirStatus BBS:PD\n");
- printf("\n");
- exit(0);
- }
- strcpy(image,argv[1]);
- sr(image);
- printf("\nDirStatus v1.0, written by Joseph Hodge\n");
- printf("\n\nPerforming validation..\n\n");
- CheckFiles();
- end();
- }
-
- void CheckFiles(void)
- {
- FILE *fi;
- char PathsFile[200];
- char Dirs[200];
- int i=0;
- int NumFound=0;
- int NumLost=0;
- sprintf(Dirs,"%s/ndirs",image);
- sprintf(PathsFile,"%s/Paths",image);
-
- if(access(PathsFile,00))
- {
- printf("Can't locate paths file\n");
- printf("Please check to insure the conference path was correct. IE:\n");
- printf("BBS:PD\n");
- end();
- }
- if(access(Dirs,00))
- {
- printf("Can't locate ndirs file\n");
- printf("Please check to insure the conference path was correct. IE:\n");
- printf("BBS:PD\n");
- end();
- }
- fi=fopen(Dirs,"r");
- fgets(Dirs,80,fi);
- fclose(fi);
- NumDirs=atoi(Dirs);
- i=1;
- while(i<=NumDirs)
- {
- printf("\nScanning dir%d...\n",i);
- sprintf(PathsFile,"%s/dir%d",image,i);
-
- NumFound=0; NumLost=0;
- fi=fopen(PathsFile,"r");
- if(fi!=NULL)
- {
- while(fgets(PathsFile,80,fi)!=NULL)
- {
- if(PathsFile[0]>32 && (PathsFile[13]=='P' || PathsFile[13]=='N'))
- {
- sr(PathsFile);
- if(!CheckForDirs(PathsFile)) NumLost +=1;
- NumFound +=1;
- }
- }
-
- fclose(fi);
- printf("\n Total Files %d, Total missing %d\n",NumFound,NumLost);
- }
- else printf(" Can't locate dir\n\n");
- i++;
- }
- }
- int CheckForDirs(char PathsFile[])
- {
- FILE *fi;
- char DirFile[200];
- char FileName[20];
- sprintf(FileName,"%-13.13s",PathsFile);
- sr(FileName);
- sprintf(DirFile,"%s/paths",image);
- fi=fopen(DirFile,"r");
- while(fgets(DirFile,80,fi)!=NULL)
- {
- sr(DirFile);
- strcat(DirFile,FileName);
- if(!access(DirFile,00)) { fclose(fi); return(1); }
- }
- fclose(fi);
- printf(" Can't locate file %s\n",FileName);
- return(0);
- }
- void sr(char *str)
- {
- register int i;
- i=strlen(str)-1;
- while(i)
- {
- if(*(str+i)<=32) *(str+i)='\0'; else return;
- i--;
- }
- }
-
- void end()
- {
- exit(0);
- }